#!/bin/bash
# Linux 32-bit/64-bit

mkdir -p linux

#cd luajit
#make clean

#make BUILDMODE=static CC="gcc -m32"
#cp src/libluajit.a ../linux/libluajit.a

#cd ..

gcc -m32 -O3 -std=gnu99 -shared \
	int64.c \
	uint64.c \
	tolua.c \
	pb.c \
	lpeg.c \
	struct.c \
	cjson/strbuf.c \
	cjson/lua_cjson.c \
	cjson/fpconv.c \
	luasocket/auxiliar.c \
	luasocket/buffer.c \
	luasocket/except.c \
	luasocket/inet.c \
	luasocket/io.c \
	luasocket/luasocket.c \
	luasocket/mime.c \
	luasocket/options.c \
	luasocket/select.c \
	luasocket/tcp.c \
	luasocket/timeout.c \
	luasocket/udp.c \
	luasocket/usocket.c \
	luasocket/compat.c \
	-o Plugins/x86/tolua.so \
	-I./ \
	-Iluajit/src \
	-Icjson \
	-Iluasocket \
	-lws2_32 \
	-Wl,--whole-archive linux/libluajit.a -Wl,--no-whole-archive -static-libgcc -static-libstdc++

# 32 Bit Version
#cd luajit
#make clean

#make BUILDMODE=static CC="gcc -fPIC -m32"
#cp src/libluajit.a ../linux/libluajit.a

#cd ..

#gcc -fPIC lua_wrap.c -o Plugins/x86/libulua.so -shared -m32 -Iluajit/src -Wl,--whole-archive linux/libluajit.a -Wl,--no-whole-archive
